<?php
declare (strict_types = 1);

namespace app\admin\validate;
use think\Validate;

class AdminUser extends Validate {
    protected $rule = [
        'code|验证码'     => 'require|captcha',
        'username|用户名' => 'require|length:2,10',
        'password|密码'   => 'require|length:6,16',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'username.length' => '用户名长度限制是2~10个字符',
        'password.length' => '密码的长度限制是6~16个字符',
        'code'            => '验证码格式不正确'
    ];

    /**
     * 定义验证场景
     * 格式：'场景名' =>  ['字段名1','字段名2']
     */
    protected $scene = [
        'login' =>  ['username', 'password', 'code']
    ];
}
